package cn.snmp.mutual.nms;

public class SnmpCounter extends SnmpUnsignedInt
{
    public SnmpCounter(final long counter) {
        super(counter);
        this.Type = 65;
    }
    
    @Override
    int encode(final byte[] bytes, final int i) throws ArrayIndexOutOfBoundsException {
        return ASNTypes.encodeUInt(bytes, i, (int)this.numberValue, 65);
    }
    
    public long getIncrement(final long l) {
        final long l2 = this.longValue();
        long l3 = l2 - l;
        if (l3 < 0L) {
            l3 = 4294967295L - (l - l2) + 1L;
        }
        return l3;
    }
    
    public long getIncrement(final SnmpCounter snmpcounter) {
        return this.getIncrement(snmpcounter.longValue());
    }
    
    @Override
    public String toTagString() {
        return "Counter : " + Long.toString(this.numberValue);
    }
}
